Repository navigation
Reclaim idle connections across routes in RouteSegmentedConnPool - #722
Merged
arturobernalg merged 1 commit intoOct 26, 2026
Merged
Conversation
arturobernalg
marked this pull request as draft
October 3, 2026 15:45
arturobernalg
force-pushed
the
offlock-cross-route-reclaim
branch
from
October 3, 2026 17:27
bc8c1b4 to
715f22a
Compare
arturobernalg
marked this pull request as ready for review
October 4, 2026 04:40
arturobernalg
force-pushed
the
offlock-cross-route-reclaim
branch
2 times, most recently
from
October 4, 2026 15:55
9159a06 to
bf93e5e
Compare
arturobernalg
force-pushed
the
offlock-cross-route-reclaim
branch
from
October 13, 2026 12:33
fb0e2f9 to
b4b5977
Compare
arturobernalg
force-pushed
the
offlock-cross-route-reclaim
branch
from
October 13, 2026 12:57
c8a2cd3 to
348f961
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RouteSegmentedConnPoolstopped allocating when the global limit was reached, even if another route held an idle reusable entry, and its hot path paid for two shared structures: the executor hand-off of every graceful close and the single deque of idle entries of each route.Three commits:
maxTotalis reached, an idle entry of another route is reclaimed and its global slot transferred to the requesting route. The hot path stays route-local; pending routes are retried when capacity appears.close()never waits on the backlog. The round-robin drain runs on a single on-demand thread signalled with a CAS. Segments are retired with a negative allocation marker before leaving the map, which fixes a global slot leak when an allocation raced the removal of a segment.Benchmarks
JMH 1.37, JDK 17, 16 cores,
-f 2 -wi 3 -w 1 -i 5 -r 1, each suite run alone.RouteSegmentedConnPoolBenchmarkhas no I/O and 8 threads unless stated;RoutePoolsJmhdrives real sockets against a local HTTP/1.1 server with 50 threads,maxTotal=100, 5 per route, and reports completed requests.hotRouteUncontended(lease hit + release, 8 threads), ops/shotRouteUncontended, 1 thread, ops/scoldRouteAtFullPoolWithIdle(reclaim atmaxTotal), ops/scoldRouteProgressUnderSameRouteBacklog, mean latencyhotRoute/hotRouteAtFullPool(1 connection, 8 threads), ops/sRoutePoolsJmh, 50 routes, 200 ms graceful close, 0 % / 20 % discards, req/sRoutePoolsJmh, 10 routes, 200 ms graceful close, 0 % / 20 % discards, req/sRoutePoolsJmh, 50 routes, instant close, 20 % discards, req/sBefore these changes OFFLOCK measured 3.6 M ops/s on
hotRouteUncontended, 1.9 M oncoldRouteAtFullPoolWithIdleand 1.4 µs on the backlog case, and the socket benchmark with slow closes did not complete.hotRoutewith a single connection and the instant-close socket rows are bound by thread hand-off latency and by the server respectively, so all three pools measure the same there. STRICT closes connections inline, which is why it leads the backlog latency with no-op closes and collapses with real ones.httpcore5: 2007 tests, Checkstyle clean.